import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        role: 0,
        user_id: null,
        token: null,
        dash: false,
        show_notify: false
    },
    getters: {
        dash: state => {
            return state.dash
        },
        role: state => {
            return state.role
        },
        user_id: state => {
            return state.user_id
        },
        token: state => {
            return state.token
        },
        show_notify: state => {
            return state.show_notify
        }
    },
    mutations: {
        storeState(state, dash) {
            state.dash = dash
        },
        storeNotify(state, show_notify) {
            state.show_notify = show_notify
        },
        storeUser(state, payload) {
            state.user_id = payload.user_id,
            state.role = payload.role
        },
        storeToken(state, token) {
            state.token = token
        }
    }
})
